package FastJson_douban;

import com.alibaba.fastjson.JSONReader;

import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class Json_txt {
    public static void main(String[] args) throws Exception {
        //因为是Json数组，因此使用JsonReader读取
        JSONReader reader = new JSONReader(new FileReader("D:\\MP\\豆瓣\\data.json"));
        BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\MP\\豆瓣\\data.txt"));
        //数组开始读取
        reader.startArray();
        while (reader.hasNext()) {
            //将Json数组的每一个元素转换成对象
            Film film = reader.readObject(Film.class);
            //写出对象
            bw.write(film.toString());
            bw.write("\n");
            //刷新，防止数据残留
            bw.flush();
        }
        //结束数组读取
        reader.endArray();
        bw.close();
    }
}
